﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TaskList.aspx.cs" Inherits="Workflow.TaskList" %>

<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="js/jquery.js" type="text/javascript"></script>
    <script src="js/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script type="text/javascript">
        function request(paras) {
            var url = location.href;
            var paraString = url.substring(url.indexOf("?") + 1, url.length).split("&");
            var paraObj = {}
            for (i = 0; j = paraString[i]; i++) {
                paraObj[j.substring(0, j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=") + 1, j.length);
            }
            var returnValue = paraObj[paras.toLowerCase()];
            if (typeof (returnValue) == "undefined") {
                return "";
            } else {
                return returnValue;
            }
        }
        function showAdv() {
            $("#divQuery").toggle();
        }

        function changeCss1(ele) {
            $(ele).css("cur");
        }

        $(document).ready(function () {
            if ($("#txtShowQuery").val() == "1") {
                $("#divQuery").show();
            }

            $("#tab td").each(function () {
                $(this).css("text-align", "center");
            });

            var type = request("Type");
            if (type.toLowerCase() == "myrequest") {
                $("td[id$='tdInitior']").each(function () {
                    $(this).css("display", "none");
                });
                $("td[id=CurrentUser]").each(function () {
                    $(this).css("display", "block");
                })
            }

        });

        function changeStatus(ele) {
            $("input[type='checkbox']").attr("checked", ele.checked);
        }
    </script>
</head>
<body>
    <style type="text/css">
        input[type='text']
        {
            height: 13px;
            width: 100px;
        }
        
        .lbl
        {
            display: inline-block;
            width: 90px;
        }
        
        .small
        {
            height: 22px;
            padding-top: 0px;
            margin-top: 0px;
        }
    </style>
    <script type="text/javascript">
        function assign() {
            var taskid = "";
            $("#tab tr").each(function () {
                if ($(this).find("td:eq(0)").children().attr("checked")) {
                    taskid += $(this).find("td:eq(0)").children()[1].innerText + ",";
                }
            });
            if (taskid != "") {
                taskid = taskid.substring(0, taskid.lastIndexOf(","));
            }
            var PageName = "Assign.aspx";
            if (taskid != "") {
                PageName += "?TaskID=" + encodeURI(taskid);
            }
            window.showModalDialog(PageName, "javascript", "dialogHeight=300px;dialogWidth=400px;scroll=no;");
            location.href = location.href;
        }

        function back() {

            var PageName = "AssignmentList.aspx";
            window.showModalDialog(PageName, "javascript", "dialogHeight=800px;dialogWidth=500px;scroll=no;");
            location.href = location.href
        }

        function Abort() {
            var iFlag = true;
            $("#tab tr").each(function () {
                if ($(this).find("td:eq(0)").children().attr("checked")) {
                    //alert($(this).find("div[id=status]")[0].innerText);
                    if ($(this).find("div[id=status]")[0].innerText == "已完成"
                    || $(this).find("div[id=status]")[0].innerText == "终止"
                    || $(this).find("div[id=status]")[0].innerText == "Completed"
                    || $(this).find("div[id=status]")[0].innerText == "Abort"
                    ) {
                        iFlag = false;
                        alert('<%=CanNotCancel %>');
                        return false;
                    }
                }
            });
            return iFlag;
        }
    </script>
    <form id="form1" runat="server">
    <div class="category_nav_box ">
        <dl class="first">
            <dt>
                <%=Workflow.Resources.lang.TaskList_ProcessCategory %>：</dt>
            <dd>
                <asp:Repeater ID="rptProcessCategory" runat="server">
                    <ItemTemplate>
                        <a href='<%#GetProcessCategoryUrl(Eval("CATEGORYNAME").ToString()) %>' class='<%#GetProcessCategoryCurCss(Eval("CATEGORYNAME").ToString()) %>'
                            target="_self">
                            <%#Eval("CategoryName") %></a>
                    </ItemTemplate>
                </asp:Repeater>
            </dd>
        </dl>
        <dl>
            <dt>
                <%=Workflow.Resources.lang.TaskList_StartTime %>：</dt>
            <dd>
                <a href='<%=GetDateTypeUrl("0") %>' class='<%=GetDateTypeCurCss("0") %>'>
                    <%=Workflow.Resources.lang.TaskList_All %></a> <a href='<%=GetDateTypeUrl("1") %>'
                        class='<%=GetDateTypeCurCss("1") %>'>
                        <%=Workflow.Resources.lang.TaskList_Week %></a> <a href='<%=GetDateTypeUrl("2") %>'
                            class='<%=GetDateTypeCurCss("2") %>'>
                            <%=Workflow.Resources.lang.TaskList_Month %></a> <a href='<%=GetDateTypeUrl("3") %>'
                                class='<%=GetDateTypeCurCss("3") %>'>
                                <%=Workflow.Resources.lang.TaskList_3Month %></a> <a class="right" href="javascript:showAdv();">
                                    <%=Workflow.Resources.lang.TaskList_AdvSearch %></a>
            </dd>
        </dl>
        <div id="divQuery" class="hide">
            <dl style="padding-top: 6px; padding-bottom: 9px">
                <dt>
                    <%=Workflow.Resources.lang.TaskList_Search %>：</dt>
                <dd>
                    <asp:Label ID="lblProcessName" runat="server" Text="流程名称" CssClass="lbl"></asp:Label>
                    <asp:TextBox ID="txtProcessName" CssClass="input-query" runat="server"></asp:TextBox>
                    <asp:Label ID="lblStartTime" runat="server" Text="开始时间" CssClass="lbl"></asp:Label>
                    <asp:TextBox ID="txtStartDate" CssClass="input-query" onclick="WdatePicker({skin:'whyGreen',dateFmt:'yyyy/MM/dd'})"
                        runat="server"></asp:TextBox>
                    <asp:Label ID="Label6" runat="server" Text="-" CssClass="lbl"></asp:Label>
                    <asp:TextBox ID="txtEndDate" CssClass="input-query" onclick="WdatePicker({skin:'whyGreen',dateFmt:'yyyy/MM/dd'})"
                        runat="server"></asp:TextBox>
                    <asp:Label ID="lbQstep" runat="server" Text="步骤名称" CssClass="lbl"></asp:Label>
                    <asp:TextBox ID="txtStepName" runat="server" CssClass="input-query"></asp:TextBox>
                </dd>
            </dl>
            <dl style="padding-top: 6px; padding-bottom: 9px">
                <dd>
                    <asp:Label ID="lblIncident" runat="server" Text="实例号" CssClass="lbl"></asp:Label>
                    <asp:TextBox ID="txtIncident" CssClass="input-query" runat="server"></asp:TextBox>
                    <asp:Label ID="lblApplicant" runat="server" Text="申请人" CssClass="lbl"></asp:Label>
                    <asp:TextBox ID="txtApplicant" CssClass="input-query" runat="server"></asp:TextBox>
                    <asp:Label ID="lblSummary" runat="server" Text="摘要" CssClass="lbl"></asp:Label>
                    <asp:TextBox ID="txtSummary" CssClass="input-query" runat="server"></asp:TextBox>
                    <asp:Button ID="btnSearch" runat="server" CssClass="btn small" Text="查询" OnClick="btnSearch_Click" />
                </dd>
            </dl>
        </div>
        <dl class="sort_order">
            <dt>
                <%=Workflow.Resources.lang.TaskList_Sort %>：</dt>
            <dd>
                <a href='<%=GetSortUrl("a.STARTTIME DESC") %>' class='<%=GetSortCurCss("0") %>'>
                    <%=Workflow.Resources.lang.TaskList_Default %></a> <a href='<%=GetSortUrl("a.STARTTIME DESC") %>'
                        class='<%=GetSortCurCss("a.STARTTIME DESC") %>'>
                        <%=Workflow.Resources.lang.TaskList_StartTime %></a> <a href='<%=GetSortUrl("a.PROCESSNAME") %>'
                            class='<%=GetSortCurCss("a.PROCESSNAME") %>'>
                            <%=Workflow.Resources.lang.TaskList_ProcessName %></a> <a href='<%=GetSortUrl("b.STATUS") %>'
                                class='<%=GetSortCurCss("b.STATUS") %>'>
                                <%=Workflow.Resources.lang.TaskList_Status %></a>
            </dd>
        </dl>
    </div>
    <div class="pt10">
    </div>
    <div>
        <table class="table table-bordered table-hover table-condensed" id="tab">
            <thead>
                <tr>
                    <th>
                        <asp:CheckBox ID="cbAll" runat="server" onclick="changeStatus(this);" />
                    </th>
                    <th>
                        <%=Workflow.Resources.lang.TaskList_Monitor%>
                    </th>
                    <th>
                        <%=Workflow.Resources.lang.TaskList_Incident%>
                    </th>
                    <th>
                        <%=Workflow.Resources.lang.TaskList_ProcessName%>
                    </th>
                    <th>
                        <%=Workflow.Resources.lang.TaskList_Summary%>
                    </th>
                     <th id="thsteplabel" runat="server" >
                        <%=Workflow.Resources.lang.TaskList_StepName%>
                    </th>
                    <%--<th id="tInitior" runat="server">
                        <%=Workflow.Resources.lang.TaskList_Initior %>
                    </th>
                    <th>
                        <%= Workflow.Resources.lang.TaskList_Department %>
                    </th>--%>
                    <th id="CurrentUser" runat="server" visible="false">
                        <%= Workflow.Resources.lang.TaskList_CurrentUser %>
                    </th>
                    <th>
                        <%=Workflow.Resources.lang.TaskList_StartTime%>
                    </th>
                    <th>
                        <%=Workflow.Resources.lang.TaskList_OverdueTime%>
                    </th>
                    <th>
                        <%=Workflow.Resources.lang.TaskList_Status%>
                    </th>
                </tr>
            </thead>
            <tbody>
                <asp:Repeater ID="rptTask" runat="server">
                    <ItemTemplate>
                        <tr>
                            <td style="width: 20px;">
                                <asp:CheckBox ID="cbSelect" runat="server" /><div class="hide">
                                    <%#Eval("TaskID") %></div>
                                <asp:HiddenField ID="hfTaskid" runat="server" Value='<%# Eval("TaskID") %>' />
                            </td>
                            <td>
                                <a href="TaskStatus.aspx?ProcessName=<%#Server.UrlEncode(Eval("PROCESSNAME").ToString().Trim()) %>&Incident=<%#Eval("INCIDENT") %>"
                                    target="_blank">
                                    <img src="images/task_monitor.gif" /></a>
                            </td>
                            <td>
                                <%#Eval("INCIDENT")%>
                            </td>
                            <td>
                                <a href="OpenForm.aspx?TaskId=<%#Eval("TaskID") %>&Type=<%=Request.QueryString["Type"] %>"
                                    target="_blank">
                                    <%#Eval("PROCESSNAME")%></a>
                            </td>
                            <td>
                                <%#Eval("SUMMARY")%>
                            </td>
                            <td id="tdsteplabel">
                                <%#Eval("STEPLABEL")%>
                            </td>
                            <%--<td id="tdInitior">
                                <%#Eval("APLICANT")%>
                            </td>
                            <td>
                                <%#Eval("DEPARTMENT")%>
                            </td>--%>
                            <td id="CurrentUser" style="display: none;">
                                <%# GetCurrentUser(Eval("PROCESSNAME").ToString(), Eval("INCIDENT").ToString())%>
                            </td>
                            <td id="status">
                                <%#Convert.ToDateTime(Eval("STARTTIME")).ToString("yyyy/MM/dd HH:mm:ss")%>
                            </td>
                            <td>
                                <%#Convert.ToDateTime(Eval("OVERDUETIME")) == DateTime.MinValue ? "" : Convert.ToDateTime(Eval("OVERDUETIME")).ToString("yyyy/MM/dd HH:mm:ss")%>
                            </td>
                            <td>
                                <div id="status">
                                    <%#GetStatus(Eval("PROCESSSTATUS").ToString()) %></div>
                            </td>
                        </tr>
                    </ItemTemplate>
                </asp:Repeater>
            </tbody>
        </table>
    </div>
    <div id="pagelist">
        <span class="left">
            <asp:Button ID="btnAssign" runat="server" CssClass="btn" Text="指派" OnClientClick="assign();return false;"
                Visible="false" />
            <asp:Button ID="btnAssignCallback" runat="server" CssClass="btn" Text="收回指派" Visible="false"
                OnClientClick="location.href='AssignmentList.aspx';return false;" />
            <asp:Button ID="btnAbort" runat="server" CssClass="btn" Visible="false" Text="取消流程"
                OnClick="btnAbort_Click" OnClientClick="return Abort();" />
        </span><span class="right">
            <webdiyer:AspNetPager ID="AspNetPager1" runat="server" CustomInfoHTML="Count %RecordCount%"
                Width="100%" CssClass="aspNetPager" OnPageChanged="AspNetPager1_PageChanged"
                AlwaysShow="true">
            </webdiyer:AspNetPager></span>
    </div>
    <div style="display: none">
        <asp:TextBox ID="txtType" runat="server"></asp:TextBox>
        <asp:TextBox ID="txtPreSort" runat="server"></asp:TextBox>
        <asp:TextBox ID="txtSort" runat="server"></asp:TextBox>
        <asp:TextBox ID="txtStartTime" runat="server"></asp:TextBox>
        <asp:TextBox ID="txtDateType" runat="server"></asp:TextBox>
        <asp:TextBox ID="txtShowQuery" runat="server"></asp:TextBox>
        <asp:TextBox ID="txtProcessCategory" runat="server"></asp:TextBox>
    </div>
    </form>
</body>
</html>
